package com.cba.service.oa.service.impl;


import com.cba.service.admin.service.IAdminUserService;
import com.cba.core.servlet.BaseServiceImpl;
import com.cba.service.oa.entity.PO.OaCalendarTypeUser;
import com.cba.service.oa.mapper.OaCalendarTypeUserMapper;
import com.cba.service.oa.service.IOaCalendarTypeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 用户关联日历类型 服务实现类
 * </p>
 *
 * @author wyq
 * @since 2020-05-15
 */
@Service
public class OaCalendarTypeUserServiceImpl extends BaseServiceImpl<OaCalendarTypeUserMapper, OaCalendarTypeUser> implements IOaCalendarTypeUserService {

//    @Autowired
//    private AdminService adminService;
    @Autowired
    private IAdminUserService adminUserService;

    @Override
    public void saveSysCalendarType(Integer typeId) {
//        Result<List<Long>> listResult = adminService.queryUserList(1);
//        List<Long> userIds = listResult.getData();
        List<Long> userIds = adminUserService.queryAllUserList(1);
        List<OaCalendarTypeUser> oaCalendarTypeUsers = new ArrayList<>();
        userIds.forEach(userId->{
            OaCalendarTypeUser oaCalendarTypeUser = new OaCalendarTypeUser();
            oaCalendarTypeUser.setTypeId(typeId);
            oaCalendarTypeUser.setUserId(userId);
            oaCalendarTypeUsers.add(oaCalendarTypeUser);
        });
        saveBatch(oaCalendarTypeUsers);
    }
}
